/* DaException - Decompiled by JODE
 * Visit http://jode.sourceforge.net/
 */
package net.da.core.exception;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Hashtable;
import java.util.ResourceBundle;


public class DaException extends Exception implements IDfException
{
    public static final int DM_API_E_BADID = -65535;
    public static final int DM_API_E_BADATTRNAME = -65534;
    public static final int DM_API_E_BADATTRINDX = -65533;
    protected String m_message;
    protected ResourceBundle m_bundle;
    protected boolean m_insideGetStackTrace = false;
    private static Hashtable s_exceptionTable = new Hashtable();
    private static boolean s_includeStackTraceInMsg
	= Boolean.getBoolean("dfc.exception.includeStack");
    private static final String THREAD = ":: THREAD: ";
    private static final String ERRORCODE = "; ERRORCODE: ";
    private static final String MSG = "; MSG: ";
    private static final String NEXT = "; NEXT: ";
    private static final String DFE_ERROR_CODE = "code";
    private static final String DFE_THREAD_INFO = "thread";
    private static final String DFE_NEXT_EXPT = "next";
    private static final String DFE_TAIL_EXPT = "tail";
    
    public DaException() {
	Throwable throwable = null;
	try {
	    setErrorCode(255);
	} catch (Throwable throwable_0_) {
	    throwable = throwable_0_;
	    if (throwable_0_ instanceof Error)
		throw (Error) throwable_0_;
	    throw (RuntimeException) throwable_0_;
	} finally {
	}
    }
    
    public DaException(int i) {
	this();
	Throwable throwable = null;
	try {
	    setErrorCode(i);
	} catch (Throwable throwable_1_) {
	    throwable = throwable_1_;
	    if (throwable_1_ instanceof Error)
		throw (Error) throwable_1_;
	    throw (RuntimeException) throwable_1_;
	} finally {
	}
    }
    
    public DaException(int i, String string) {
	this();
	Throwable throwable = null;
	try {
	    setErrorCode(i);
	    m_message = string;
	} catch (Throwable throwable_2_) {
	    throwable = throwable_2_;
	    if (throwable_2_ instanceof Error)
		throw (Error) throwable_2_;
	    throw (RuntimeException) throwable_2_;
	} finally {
	}
    }
    
    public DaException(int i, String string, String string_3_,
		       String string_4_) {
	this();
	Throwable throwable = null;
	try {
	    setErrorCode(i);
//	    m_message
//		= DfUtil.getDFCBundleString(i, string, string_3_, string_4_);
	    switch (i) {
	    case -65535:
	    case -65534:
	    case -65533:
		setErrorCode(256);
		break;
	    }
	} catch (Throwable throwable_5_) {
	    throwable = throwable_5_;
	    if (throwable_5_ instanceof Error)
		throw (Error) throwable_5_;
	    throw (RuntimeException) throwable_5_;
	} finally {
	}
    }
    
    public DaException(ResourceBundle resourcebundle, int i) {
	this(resourcebundle, i, null, null, null);
	Throwable throwable = null;
    }
    
    public DaException(ResourceBundle resourcebundle, int i, String string,
		       String string_7_, String string_8_) {
	this();
	Throwable throwable = null;
	try {
	    setErrorCode(i);
//	    m_message
//		= DfUtil.getBundleString(resourcebundle, DfUtil.toString(i),
//					 string, string_7_, string_8_);
	    m_bundle = resourcebundle;
	} catch (Throwable throwable_9_) {
	    throwable = throwable_9_;
	    if (throwable_9_ instanceof Error)
		throw (Error) throwable_9_;
	    throw (RuntimeException) throwable_9_;
	} finally {
	}
    }
    
    public void setErrorCode(int i) {
    }
    
    public int getErrorCode() {
	    return 0;
    }
    
    public void setMessage(String string) {
	    m_message = string;
    }
    
    public String getMessage() {
	String string = null;
	Throwable throwable = null;
	Object object = null;
	try {
	    String string_15_ = getMessageImp();
	    if (s_includeStackTraceInMsg)
		string_15_ += getStackTraceAsString();
	    string = string_15_;
	    return string;
	} catch (Throwable throwable_16_) {
	    throwable = throwable_16_;
	    if (throwable_16_ instanceof Error)
		throw (Error) throwable_16_;
	    throw (RuntimeException) throwable_16_;
	} finally {
    }
    }
    
    protected String getMessageImp() {
	String string = null;
	Throwable throwable = null;
	Object object = null;
	try {
	    String string_17_;
	    if (m_message == null) {
		try {
		    if (m_bundle == null) {
//			string_17_ = DfUtil.getDFCBundleString(getErrorCode());
                    }
		    else {
//			string_17_
//			    = (DfUtil.getBundleString
//			       (m_bundle, DfUtil.toString(getErrorCode())));
                    }
		} catch (Exception exception) {
		    string_17_ = "";
		}
	    } else
		string_17_ = m_message;
//	    string = string_17_;
	    return string;
	} catch (Throwable throwable_18_) {
	    throwable = throwable_18_;
	    if (throwable_18_ instanceof Error)
		throw (Error) throwable_18_;
	    throw (RuntimeException) throwable_18_;
	} finally {
	}
    }
    
    public String getThreadInfo() {
	return "";
    }

    
    public String getStackTraceAsString() {
	String string = null;
	Throwable throwable = null;
	Object object = null;
	try {
	    m_insideGetStackTrace = true;
	    try {
		StringWriter stringwriter = new StringWriter();
		PrintWriter printwriter = new PrintWriter(stringwriter);
		this.printStackTrace(printwriter);
		printwriter.flush();
		string = stringwriter.toString();
		return string;
	    } finally {
		m_insideGetStackTrace = false;
	    }
	} catch (Throwable throwable_22_) {
	    throwable = throwable_22_;
	    if (throwable_22_ instanceof Error)
		throw (Error) throwable_22_;
	    throw (RuntimeException) throwable_22_;
	}
    }
    
    public IDfException getNextException() {
		return null;
    }
    
    public String toString() {
	if (m_insideGetStackTrace)
	    return "";
	String string = (getClassName() + ":: THREAD: " + getThreadInfo()
			 + "; MSG: " + getMessageImp().trim() + "; ERRORCODE: "
			 + Integer.toHexString(getErrorCode()) + "; NEXT: "
			 + (getNextException() != null
			    ? getNextException().toString() : "null"));
	if (s_includeStackTraceInMsg)
	    string += getStackTraceAsString();
	putException(getThreadInfo(), this);
	return string;
    }
    
    public int getCount() {
	int i = 0;
	Throwable throwable = null;
	Object object = null;
	try {
	    IDfException idfexception = this;
	    int i_25_ = 0;
	    while (idfexception != null) {
		idfexception = idfexception.getNextException();
		i_25_++;
	    }
	    i = i_25_;
	    return i;
	} catch (Throwable throwable_26_) {
	    throwable = throwable_26_;
	    if (throwable_26_ instanceof Error)
		throw (Error) throwable_26_;
	    throw (RuntimeException) throwable_26_;
	}
    }
    
    public IDfException getTailException() {
	DaException dfexception_27_ = null;
	Throwable throwable = null;
	Object object = null;
	try {
	    DaException dfexception_28_ = null;
	    dfexception_27_ = dfexception_28_;
	    return dfexception_27_;
	} catch (Throwable throwable_29_) {
	    throwable = throwable_29_;
	    if (throwable_29_ instanceof Error)
		throw (Error) throwable_29_;
	    throw (RuntimeException) throwable_29_;
	}
    }
    
    public static IDfException parseException(String string) {
	DaException dfexception = null;
	Throwable throwable = null;
	Object object = null;
	try {
	    int i = string.indexOf(":: THREAD: ");
	    DaException dfexception_31_;
	    if (i >= 0) {
		i += ":: THREAD: ".length();
		int i_32_ = string.indexOf("; MSG: ");
		String string_33_ = string.substring(i, i_32_);
		dfexception_31_ = getException(string_33_);
		if (dfexception_31_ == null) {
		    dfexception_31_ = new DaException(255);
		    dfexception_31_.setMessage(string);
		}
	    } else {
		int i_34_;
		if (string.indexOf("java.") >= 0)
		    i_34_ = 1;
		else
		    i_34_ = 0;
		dfexception_31_ = new DaException(i_34_);
		dfexception_31_.setMessage(string);
	    }
	    dfexception = dfexception_31_;
	    return dfexception;
	} catch (Throwable throwable_35_) {
	    throwable = throwable_35_;
	    if (throwable_35_ instanceof Error)
		throw (Error) throwable_35_;
	    throw (RuntimeException) throwable_35_;
	}
    }
    
    /**
     * @deprecated
     */
    public static synchronized void setIncludeStackTraceInMsg(boolean bool) {
	Throwable throwable = null;
	Object object = null;
	try {
	    s_includeStackTraceInMsg = bool;
	} catch (Throwable throwable_36_) {
	    throwable = throwable_36_;
	    if (throwable_36_ instanceof Error)
		throw (Error) throwable_36_;
	    throw (RuntimeException) throwable_36_;
	}
    }
    
    protected String getClassName() {
	String string = null;
	Throwable throwable = null;
	Object object = null;
	try {
	    String string_40_ = this.getClass().getName();
	    string = string_40_.substring(string_40_.lastIndexOf('.') + 1);
	    return string;
	} catch (Throwable throwable_41_) {
	    throwable = throwable_41_;
	    if (throwable_41_ instanceof Error)
		throw (Error) throwable_41_;
	    throw (RuntimeException) throwable_41_;
	}
    }
    
    protected static synchronized DaException getException(String string) {
	DaException dfexception = null;
	Throwable throwable = null;
	Object object = null;
	try {
	    DaException dfexception_45_ = null;
	    if (string != null && string.length() > 0)
		dfexception_45_ = (DaException) s_exceptionTable.get(string);
	    dfexception = dfexception_45_;
	    return dfexception;
	} catch (Throwable throwable_46_) {
	    throwable = throwable_46_;
	    if (throwable_46_ instanceof Error)
		throw (Error) throwable_46_;
	    throw (RuntimeException) throwable_46_;
	}
    }
    
    protected static synchronized void putException(String string,
						    DaException dfexception) {
	Throwable throwable = null;
	Object object = null;
	try {
	    if (string != null && string.length() > 0)
		s_exceptionTable.put(string, dfexception);
	} catch (Throwable throwable_47_) {
	    throwable = throwable_47_;
	    if (throwable_47_ instanceof Error)
		throw (Error) throwable_47_;
	    throw (RuntimeException) throwable_47_;
	}
    }
}
